package net.lab1024.sa.admin.module.aneswork.pacu;

import io.swagger.v3.oas.annotations.Operation;
import net.lab1024.sa.admin.module.aneswork.pacu.domain.PacuWorkEntity;
import net.lab1024.sa.admin.module.aneswork.pacu.domain.PacuWorkTimeEntity;
import net.lab1024.sa.admin.module.aneswork.pacu.domain.form.PacuWorkQueryForm;
import net.lab1024.sa.base.common.domain.PageResult;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.ValidateList;
import net.lab1024.sa.base.module.support.apiencrypt.annotation.ApiDecrypt;
import net.lab1024.sa.base.module.support.apiencrypt.annotation.ApiEncrypt;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
public class PacuWokrController {


    @Resource
    private PacuworkService pacuworkService;

    @ApiDecrypt
    @ApiEncrypt
    @Operation(summary = "查询PACU工作时间-加密")
    @PostMapping("/pacu/time/query/encrypt")
    public ResponseDTO<PacuWorkTimeEntity> queryByPageEncrypt() {
        return pacuworkService.queryWorkTimesByUser();
    }


    @ApiDecrypt
    @ApiEncrypt
    @Operation(summary = "新增PACU工作时间")
    @PostMapping("/pacu/time/add")
    public ResponseDTO<String> addTime(@RequestBody @Valid PacuWorkTimeEntity data) {
        return pacuworkService.addTime(data);
    }


    @ApiDecrypt
    @ApiEncrypt
    @Operation(summary = "更新pacu工作时间")
    @PostMapping("/pacu/time/update")
    public ResponseDTO<String> updateTime(@RequestBody @Valid PacuWorkTimeEntity data) {
        return pacuworkService.updateTime(data);
    }

    @ApiDecrypt
    @ApiEncrypt
    @Operation(summary = "查询PACU记录")
    @PostMapping("/pacuWork/queryPage")
    public ResponseDTO<PageResult<PacuWorkEntity>> queryPage(@RequestBody @Valid PacuWorkQueryForm queryForm) {
        return ResponseDTO.ok(pacuworkService.queryPage(queryForm));
    }

    @ApiDecrypt
    @ApiEncrypt
    @Operation(summary = "新增PACU")
    @PostMapping("/pacu/add")
    public ResponseDTO<String> add(@RequestBody @Valid PacuWorkEntity data) {
        return pacuworkService.add(data);
    }


    @ApiDecrypt
    @ApiEncrypt
    @Operation(summary = "更新pacu")
    @PostMapping("/pacu/update")
    public ResponseDTO<String> update(@RequestBody @Valid PacuWorkEntity data) {
        return pacuworkService.update(data);
    }

    @Operation(summary = "批量删除PACU")
    @PostMapping("/pacu/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return pacuworkService.batchDelete(idList);
    }

    @Operation(summary = "单个删除PACU")
    @GetMapping("/pacu/delete/{id}")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return pacuworkService.delete(id);
    }
}
